/*
 * TextObject.h
 *
 *  Created on: 2009/02/17
 *      Author: Yongshik Cho
 */

#ifndef TEXTOBJECT_H_
#define TEXTOBJECT_H_

#include <vector>
#include "RenderObject.h"
#include "sqplus/sqplus.h"
using namespace SqPlus;


class TextObject : public RenderObject
{
public:
	static const uint32 _DEFAULT_STEP_COUNT			= 8;

	static const uint8 TEXT_BITMAP					= 0x0;
	static const uint8 TEXT_OUTLINE					= 0x1;

	static const uint8 	LINE_NONE					= 0x0;
	static const uint8 	LINE_SOLID					= 0x1;

	static const uint8 	FILL_NONE					= 0x0;
	static const uint8 	FILL_SOLID					= 0x1;

private:
	typedef vector<uint8*> TextBitmapList;
	typedef vector<GLYPHMETRICS> GlyphMetricsList;

public:
	TextObject();
	virtual ~TextObject();

public:
	inline const String& getText() const { return mText; }
	void setText(const String& text, bool create = true);

	virtual const Color& getLineColor() const { return mLineColor; }
	virtual void setLineColor(const Color& color) { mLineColor = color; }
	virtual const Color getFillColor() const { return mFillColor; }
	virtual void setFillColor(const Color& color, bool create = true);
	virtual const Color getBackColor() const { return mBackColor; }
	virtual void setBackColor(const Color& color, bool create = true);
	virtual const uint8 getLineStyle() const { return mLineStyle; }
	virtual void setLineStyle(uint8 style) { mLineStyle = style; }
	virtual const uint8 getFillStyle() const { return mFillStyle; }
	virtual void setFillStyle(uint8 style, bool create = true);
	virtual const uint8 getTextStyle() const { return mTextStyle; }
	virtual void setTextStyle(uint8 style, bool create = true);

	virtual const String& getFaceName() const { return mFaceName; }
	virtual void setFaceName(const String& face, bool create = true);

	virtual const int32 getWidth() const { return mWidth; }
	virtual void setWidth(int32 width, bool create = true);
	virtual const int32 getHeight() const { return mHeight; }
	virtual void setHeight(int32 height, bool create = true);
	virtual const int32 getEscapement() const { return mEscapement; }
	virtual void setEscapement(int32 escape, bool create = true);
	virtual const int32 getOrientation() const { return mOrientation; }
	virtual void setOrientation(int32 orient, bool create = true);
	virtual const int32 getWeight() const { return mWeight; }
	virtual void setWeight(int32 weight, bool create = true);

	virtual const bool getItalic() const { return mItalic; }
	virtual void setItalic(bool italic, bool create = true);
	virtual const bool getUnderline() const { return mUnderline; }
	virtual void setUnderline(bool underline, bool create = true);
	virtual const bool getStrikeout() const { return mStrikeout; }
	virtual void setStrikeout(bool strike, bool create = true);

	virtual const uint8 getOutPrecision() const { return mOutPrecision; }
	virtual void setOutPrecision(uint8 out, bool create = true);
	virtual const uint8 getClipPrecision() const { return mClipPrecision; }
	virtual void setClipPrecision(uint8 clip, bool create = true);
	virtual const uint8 getQuality() const { return mQuality; }
	virtual void setQuality(uint8 quality, bool create = true);
	virtual const uint8 getPitchAndFamily() const { return mPitchAndFamily; }
	virtual void setPitchAndFamily(uint8 paf, bool create = true);

private:
	void createTextBitmap();
	void createText_Bitmap(TextBitmapList& list, const uint32 w, const uint32 h);
	void releaseTextBitmapList(TextBitmapList& list);
	void selectFont();

private:
	String		mText;
	Color		mLineColor;
	Color		mFillColor;
	uint8		mLineStyle;
	uint8		mFillStyle;
	uint8		mTextStyle;
	Color		mBackColor;

	int32		mWidth;
	int32		mHeight;
	int32		mEscapement;
	int32		mOrientation;
	int32		mWeight;
	bool		mItalic;
	bool		mUnderline;
	bool		mStrikeout;
	uint8		mOutPrecision;
	uint8		mClipPrecision;
	uint8		mQuality;
	uint8		mPitchAndFamily;
	String		mFaceName;

	GlyphMetricsList	mGlyphMetrics;
};

//must be declared here
DECLARE_INSTANCE_TYPE(TextObject)

#endif /* TEXTOBJECT_H_ */
